import toolMgr from '@/biz/base/tool.js'
import dt from '@dt/dt'

let _this = null

function options(vm) {
  _this = vm
  let back =
    _this.info.status == 'BACK'
      ? [
          {
            title: '退回原因',
            key: 'backReason',
            text: {}
          }
        ]
      : []
  return [
    {
      title: '套数',
      text: {},
      data: {
        from: (info) => {
          return info.roomCount + '套'
        }
      }
    },
    {
      title: '总签约金额',
      text: {},
      key: 'sumAmount',
      data: {
        from: (info) => {
          return dt.tool.formatterMoney(info.sumAmount) + '元'
        }
      }
    },
    {
      title: '实际结算佣金',
      key: 'actualCommissionAmount',
      text: {},
      data: {
        from: (info) => {
          return dt.tool.formatterMoney(info.actualCommissionAmount) + '元'
        }
      }
    },
    {
      title: '状态',
      key: 'status',
      text: {
        type: 'dict',
        key: 'commissionStatus'
      }
    },
    {
      title: '开票状态',
      key: 'invoicingStatusStr',
      text: {},
      data: {
        from: (info) => {
          return info.status == 'SETTLED' ? info.invoicingStatusStr : ''
        }
      }
    },
    {
      title: '核销状态',
      key: 'settlementStatusStr',
      text: {},
      data: {
        from: (info) => {
          return info.status == 'SETTLED' ? info.settlementStatusStr : ''
        }
      }
    },
    {
      title: '电子版附件',
      key: 'digitalAttaches',
      col: 24,
      tag: {
        type: 'text',
        closable: false,
        options: _this.info.digitalAttaches?.map((item) => {
          return {
            value: item.fileName,
            key: item.attachAddress
          }
        }),
        color: 'blue',
        click: (tag) => {
          toolMgr.downloadFile(tag.key, tag.value)
        }
      }
    },
    {
      title: '我司凭证',
      key: 'ourVoucherAttaches',
      col: 24,
      tag: {
        type: 'text',
        closable: false,
        options: _this.info.ourVoucherAttaches?.map((item) => {
          return {
            value: item.fileName,
            key: item.attachAddress
          }
        }),
        color: 'blue',
        click: (tag) => {
          toolMgr.downloadFile(tag.key, tag.value)
        }
      }
    },
    {
      title: '备注',
      key: 'remark',
      text: {},
      col: 24
    },
    ...back
  ]
}

export default {
  options
}
